//    Copyright (C) Kherty.  All rights reserved.
using System.IO.Packaging;
using System.Xml;
using OpenLS.Core.Serialization;
using OpenLS.Drawing.Serialization;

namespace OpenLS.Drawing
{
    public class GroupShapeProperties : IOfficeXmlSerializable
    {
        private BlackWhiteMode blackWhiteMode;
        private EffectProperties effectProperties;
        private FillProperties fillProperties;
        private Geometry geometry;
        private LineProperties ln;
        private Scene3D scene3D;
        private Shape3D shape3D;
        private GroupTransform2D transform2D;

        public Shape3D Shape3D
        {
            get { return shape3D; }
            set { shape3D = value; }
        }


        public Scene3D Scene3D
        {
            get { return scene3D; }
            set { scene3D = value; }
        }

        public EffectProperties EffectProperties
        {
            get { return effectProperties; }
            set { effectProperties = value; }
        }


        public LineProperties LineProperties
        {
            get { return ln; }
            set { ln = value; }
        }


        public FillProperties FillProperties
        {
            get { return fillProperties; }
            set { fillProperties = value; }
        }


        public Geometry Geometry
        {
            get { return geometry; }
            set { geometry = value; }
        }


        public GroupTransform2D Transform
        {
            get { return transform2D; }
            set { transform2D = value; }
        }

        public BlackWhiteMode BlackWhiteMode
        {
            get { return blackWhiteMode; }
            set { blackWhiteMode = value; }
        }

        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (var c = context.ReadAndSwitch("grpSpPr", DrawingConstants.DrawingNamespaceUri, false))
            {
                BlackWhiteMode = c.GetOptionalEnum("bwMode", BlackWhiteMode.Auto);
                Transform = c.ReadOptionalElement<GroupTransform2D>("xfrm");
                Geometry = Geometry.ReadGeometry(c);
                FillProperties = FillProperties.ReadFillProperties(c);
                LineProperties = c.ReadOptionalElement<LineProperties>("ln");
                EffectProperties = EffectProperties.ReadEffectProperties(c);
                Scene3D = c.ReadOptionalElement<Scene3D>(Scene3D.xmlName);
                shape3D = c.ReadOptionalElement<Shape3D>("sp3d");
                c.WarnIf("ext");
            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.WriteAndSwitch("grpSpPr", DrawingConstants.DrawingNamespace))
            {
                c.SetOptionalEnum("bwMode", BlackWhiteMode, BlackWhiteMode.Auto);
                c.WriteOptionalElement(Transform);
                c.WriteOptionalElement(Geometry);
                c.WriteOptionalElement(FillProperties);
                c.WriteOptionalElement(LineProperties);
                c.WriteOptionalElement(EffectProperties);
                c.WriteOptionalElement(Scene3D);
                c.WriteOptionalElement(Shape3D);
                c.WarnIf("ext");
            }
        }

        #endregion
    }
}